package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 数据字典-合同状态
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/25 22:00
 * @since v1.0
 */
@Getter
public enum ContractStatusEnum {
    /**
     *
     */
    SIGNING("1", "enum.contractStatus.name.signing","signing", 1),
    EXECUTION("2", "enum.contractStatus.name.execution","execution", 1),
    COMPLETE("3", "enum.contractStatus.name.complete","complete", 1),
    TERMINATION("4", "enum.contractStatus.name.termination","termination", 0),
    ;
    private String code;
    private String name;
    private String attr;

    private Integer addtionnalField;

    ContractStatusEnum(String code, String name, String attr, Integer addtionnalField) {
        this.code = code;
        this.name = name;
        this.attr = attr;
        this.addtionnalField = addtionnalField;
    }
    /**
     * 合同状态：签约，执行中，完毕，不统计终止
     *
     * @return java.util.List<java.lang.String>
     * @author 徐俊杰
     * @date 2019/6/11 9:30
     * @since v1.0
     */
    public static List<String> getCode4Remind() {
        return Arrays.asList(SIGNING.code, EXECUTION.code, COMPLETE.code);
    }

    public static ContractStatusEnum getByCode(String code) {
        for (ContractStatusEnum cache : values()) {
            if (Objects.equals(code, cache.code)) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
